<?php

use yii\db\Migration;

/**
 * Handles the creation of table `awards`.
 */
class m181104_054046_create_awards_table extends Migration
{
    /**
     * @return bool|void
     * @throws \yii\db\Exception
     * @author thanatos <thanatos915@163.com>
     */
    public function safeUp()
    {
        $this->createTable('awards', [
            'id' => $this->primaryKey()->unsigned(),
            'name_awards' => $this->string(32)->notNull()->comment('奖项名'),
            'name' => $this->string(32)->notNull()->comment('奖品名'),
            'img_name' => $this->string(32)->notNull()->comment('奖品图片'),
            'num' => $this->integer(11)->notNull()->comment('奖项数'),
            'probability' => $this->tinyInteger(1)->notNull()->comment('中间概率'),
            'created_at' => $this->integer(11)->notNull()->defaultValue(0)->comment('创建时间'),
        ]);

        Yii::$app->db->createCommand()->batchInsert('awards', ['name_awards' ,'name', 'img_name', 'num', 'probability', 'created_at'], [
            ['一等奖 10名' ,'价值139元PB套装1盒', 'pb.jpg', '10', '4', time()],
            ['二等奖 50名' ,'价值119元康体霜1盒', 'kts.jpg', '50', '10', time()],
            ['三等奖 200名' ,'马拉松PB兔1只', 'pbtu.jpg', '200', '20', time()],
            ['四等奖 2740名' ,'价值24元防护油1盒', 'fhy.jpg', '2740', '66', time()],
        ])->execute();

    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('awards');
    }
}
